import numpy as np

def rotary_embedding(position, i, dim):
    angle = (position * i) / np.power(10000, i / (dim / 2))
    return np.sin(angle) if i % 2 == 0 else np.cos(angle)

def rotary_positional_embedding(seq_len, dim):
    pos_encoding = np.array([
        [rotary_embedding(pos, i, dim) for i in range(dim)]
        for pos in range(seq_len)
    ])
    return pos_encoding

seq_len = 100
dim = 512
pos_encoding = rotary_positional_embedding(seq_len, dim)
print(pos_encoding.shape)